package com.initialize.pub.dao;

import com.initialize.pub.generate.pojo.Comments;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: jane
 * Date: 2020/3/3
 * Time: 5:13 下午
 * Description:
 */
@Repository
public interface CommentsDAO {
    @Select({
            "SELECT\n" +
                    "\tcomments.cid, \n" +
                    "\tcomments.aid, \n" +
                    "\tcomments.ccid, \n" +
                    "\tcomments.`name`, \n" +
                    "\tcomments.content, \n" +
                    "\tcomments.email, \n" +
                    "\tcomments.add_the_time\n" +
                    "FROM\n" +
                    "\tcomments\n" +
                    "\tWHERE comments.aid = #{aid} AND status = 1"
    })
    @Results({
            @Result(column = "cid", property = "cid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "ccid", property = "ccid", jdbcType = JdbcType.INTEGER),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "content", property = "content", jdbcType = JdbcType.VARCHAR),
            @Result(column = "add_the_time", property = "addTheTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "email", property = "email", jdbcType = JdbcType.VARCHAR),
            @Result(column = "aid", property = "aid", jdbcType = JdbcType.INTEGER)
    })
    List<Comments> selByAid(@Param("aid") String aid);
}